import type { AddCartData, CartItemResult } from '@/types/cart'
import request from '@/utils/request/request'

/**
 * 获取全部购物车列表
 * @returns
 */
export const getAllCartListAPI = () => {
  return request<CartItemResult[]>({
    method: 'GET',
    url: '/shoppingCart/list',
  })
}
/**
 * 获取商家购物车列表
 * @returns
 */
export const getCartListAPI = (businessId: number) => {
  return request<CartItemResult[]>({
    method: 'GET',
    url: `/shoppingCart/list/${businessId}`,
  })
}
/**
 * 添加购物车
 * @returns
 */
export const addCartAPI = (data: AddCartData) => {
  return request({
    method: 'POST',
    url: '/shoppingCart/add',
    data: data,
  })
}
/**
 * 删除购物车商品
 * @param data
 * @returns
 */
export const deleteCartAPI = (data: AddCartData) => {
  return request({
    method: 'POST',
    url: '/shoppingCart/sub',
    data: data,
  })
}
/**
 * 清空购物车
 * @returns
 */
export const clearCartAPI = () => {
  return request({
    method: 'DELETE',
    url: '/shoppingCart/clean',
  })
}
